<html>
 <head>
 <script type="text/javascript">
 function generateCookieString(key, value, options) {
    key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent);
    key = key.replace(/\(/g, '%28').replace(/\)/g, '%29');
    value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent);
    options = options || {};

    var cookieString = key + '=' + value;
    cookieString += options.path ? '; Path=' + options.path : '';
    cookieString += options.domain ? '; Domain=' + options.domain : '';
    cookieString += options.expires ? '; Expires=' + options.expires.toUTCString() : '';
    cookieString += options.secure ? '; Secure' : '';

    console.log(cookieString)
    return cookieString;
};
function setCookie() {
    var name = "SessionCookie"
    var value = "QtWebEngineCookieTest"
    document.cookie = generateCookieString(name, value, {})

    name = "CookieWithExpiresField"
    value = "QtWebEngineCookieTest"
    var daysValid = 10;
    var date = new Date();
    date.setTime(date.getTime() + (daysValid*24*60*60*1000));
    var expires = date;
    var options = {};
    options.expires = expires;
    document.cookie = generateCookieString(name, value, options)
}
</script>
 </head>
 <body onload="setCookie()">
 </body>
</html>
